# Python函数式编程（map()、filter()和reduce()）详解
## python map 函数
'''
map(function, iterable)
'''
listDemo = [1, 2, 3, 4, 5]
new_list = map(lambda x: x * 2, listDemo)
print(list(new_list))
print()

listDemo1 = [1, 2, 3, 4, 5]
listDemo2 = [3, 4, 5, 6, 7]
new_list = map(lambda x, y: x + y, listDemo1, listDemo2)
print(list(new_list))
print()

## python filter 函数
'''
filter(function, iterable)
'''
listDemo = [1, 2, 3, 4, 5]
new_list = filter(lambda x: x % 2 == 0, listDemo)
print(list(new_list))
print()

## python reduce 函数
'''
reduce(function, iterable)
'''
import functools
listDemo = [1, 2, 3, 4, 5]
product = functools.reduce(lambda x, y: x * y, listDemo)
print(product)
